#ifndef __LEVELS_H__
#define __LEVELS_H__

#include <iostream>
#include <fstream>
#include <SDL2/SDL.h>
#include <vector>
#include "NpcItem.h"
#include "player.h"
#include "gamepad.h"

class cFire;
class cBowser;
class NpcItem;

class cScene
{
   public:
	cScene();
	/*LOADINGS::*/
	void loadLevel(char* scenename,int startpoint);
	void checkItems(cPlayer* mario);
	void bulletBeatItems(NpcItem *bullet);
	void updateFire();
	void changescreen();
	void getParts(char *Text);
	void interpreteSceneLine();
	/*EXCECUTATION::*/
	void drawLevel();
	void saveLevel();
	void loadGame();
	void updateBowser(cPlayer *mario, SDL_Surface *screen);
	void initBackground();
	void drawBackground();
	bool back_type;
	#define MAX_BACK 40
	int back_x[MAX_BACK];
	int back_y[MAX_BACK];
	int back_T[MAX_BACK];

	void unloadLevel();

	int posValid(int x,int y);
	int touchBonus(int x,int y);
	void BonusCheck(int x1,int y1,int x2,int y2);
	void castlelation();
	bool castled;
		
	//void updatePhysic();

	int Bonus_Kick_Mode;

	int partcount;
	char **parts;
	std::ifstream ifs;
	bool tileread;
	bool bonusread;
	bool coinread;
	float COINcount;

	int BGCOLOR;
	char* nowlevel,*RESTARTLevel;
	
	int TEXTUREcount;
	
	#define MAX_X 400
	#define MAX_Y 100
	int TILE[MAX_X][MAX_Y];

	bool COIN[MAX_X][MAX_Y];
	
	int BONUS[MAX_X][MAX_Y];

	#define MAX_TEXTURES 100
	#define MAX_BONUS_TEXTURES 21
	SDL_Surface* Textures[MAX_TEXTURES];
	SDL_Surface* Bonus_Textures[MAX_BONUS_TEXTURES];
	SDL_Surface* SAVE_SURFACE,*Background_Sky,*Background_Sky_Night;

	int VTiles,HTiles;

	struct START_POINT
	{
		int x,y;
		int type;
	}STARTPOINTS[5];
	struct EXIT_POINT
	{
		int x,y;
		char* level;
		int type;
		int startpoint;
	}EXITPOINTS[5];
	struct CASTELSTR
	{
		bool available;
		int x,y;
		bool big;
		char* level;
		int startpoint;
		SDL_Surface* small_s;
		SDL_Surface* big_s,*flag;
	}CASTLE;

	SDL_Rect SCREEN_RECT;
private:
	std::vector<NpcItem *> enemies;
	int TURTLEcount;
	cBowser* bowser;
	cFire* fire;
	void TheGameEndsHere();
};

#endif
